package com.xwj.entity;

import com.xwj.Enums.HouseMetaDataEnum;
import org.apache.commons.lang3.StringUtils;

import java.beans.Transient;
import java.io.Serializable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 租赁单明细
 */
public class OrderDetailEntity implements Serializable {
    private static final long serialVersionUID = -8352216587842984025L;

    private int number; //人数

    private double rent;//租金

    private Map<String, Object> metaData = new ConcurrentHashMap<>(); //元数据：水电费，其他费用等

    private String payRentTime; //交租时间

    private String moveTime; //入住时间

    private String longRent; //是否长期

    private int lease; //租期：如3个月

    private String effectTime; //生效时间

    private String expireTime;//租约到期时间

    private Map<String, String> membersIdCard = new ConcurrentHashMap<>(); //成员姓名和身份证号码

    private String txt;//其他说明或约定

    public OrderDetailEntity() {
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public double getRent() {
        return rent;
    }

    public void setRent(double rent) {
        this.rent = rent;
    }

    public Map<String, Object> getMetaData() {
        return metaData;
    }

    public void setMetaData(Map<String, Object> metaData) {
        this.metaData = metaData;
    }

    public String getPayRentTime() {
        return payRentTime;
    }

    public void setPayRentTime(String payRentTime) {
        this.payRentTime = payRentTime;
    }

    public String getMoveTime() {
        return moveTime;
    }

    public void setMoveTime(String moveTime) {
        this.moveTime = moveTime;
    }

    public String getLongRent() {
        return longRent;
    }

    public void setLongRent(String longRent) {
        this.longRent = longRent;
    }

    public int getLease() {
        return lease;
    }

    public void setLease(int lease) {
        this.lease = lease;
    }

    public String getEffectTime() {
        return effectTime;
    }

    public void setEffectTime(String effectTime) {
        this.effectTime = effectTime;
    }

    public String getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(String expireTime) {
        this.expireTime = expireTime;
    }

    public Map<String, String> getMembersIdCard() {
        return membersIdCard;
    }

    public void setMembersIdCard(Map<String, String> membersIdCard) {
        this.membersIdCard = membersIdCard;
    }

    public String getTxt() {
        return txt;
    }

    public void setTxt(String txt) {
        this.txt = txt;
    }

    @Transient
    public void setWaterRate(String waterRate) {
        metaData.put(HouseMetaDataEnum.WaterRate.getName(), waterRate);
    }

    @Transient
    public void setElectricityFee(String electricityFee) {
        metaData.put(HouseMetaDataEnum.ElectricityFee.getName(), electricityFee);
    }

    @Transient
    public void setExtralFee(String extralFee) {
        metaData.put(HouseMetaDataEnum.ExtralFee.getName(), extralFee);
    }

    @Transient
    public void setMemberIdCardStr(String memberIdCardStr) {
        if (StringUtils.isBlank(memberIdCardStr))
            return;
        String[] str = memberIdCardStr.split(";");
        for (int i = 0; i < str.length; i++) {
            if (str[i] != null && str[i].length() > 0) {
                String item[] = str[i].split(",");
                membersIdCard.put(item[0], item[1]);
            }
        }
    }
}
